<?php

use swap\binder;
use swap\visitor;

class my_resume_lefter_helper extends \swap\helper {
    
    public static function run() {
        $resume_id = g_int('id');
        $resume = resume_model::get_by_id($resume_id);
        binder::bind($resume, 'has_one', 'resume_ext', 'resume_id', 'resume_ext');
        
        $letters = letter_model::get_letters_by_user_id(visitor::get_role_id('user'));
        
        // 简历内容
        $lefter_naves = array(
            array('title' => '个人信息', 'url' => url('my-resume/user_info?id=' . $resume_id), 'setting' => ($resume->resume_ext->user_info_id !== '')),
            array('title' => '自我评价', 'url' => url('my-resume/myself?id=' . $resume_id), 'setting' => ($resume->resume_ext->myself_id !== '')),
            array('title' => '求职意向', 'url' => url('my-resume/intention?id=' . $resume_id), 'setting' => ($resume->resume_ext->intention_id !== '')),
            array('title' => '工作经验', 'url' => url('my-resume/experience?id=' . $resume_id), 'setting' => ($resume->resume_ext->experience_id !== '')),
            array('title' => '教育背景', 'url' => url('my-resume/education?id=' . $resume_id), 'setting' => ($resume->resume_ext->education_id !== '')),
            array('title' => '培训经历', 'url' => url('my-training/index?id=' . $resume_id), 'setting' => ($resume->resume_ext->training_id !== '')),
            array('title' => '语言能力', 'url' => url('my-language/index?id=' . $resume_id), 'setting' => ($resume->resume_ext->language_id !== '')),
            array('title' => '求职信', 'url' => url('my-letter/index'), 'setting' => isset($letters)),
            array('title' => '证书', 'url' => url('my-resume/certificate?id=' . $resume_id), 'setting' => ($resume->resume_ext->certificate_id !== '')),
            array('title' => '照片', 'url' => url('my-resume/picture?id=' . $resume_id), 'setting' => ($resume->resume_ext->picture_id !== '')),
            array('title' => '附件', 'url' => url('my-resume/attachment?id=' . $resume_id), 'setting' => ($resume->resume_ext->attachment_id !== '')),
            array('title' => '其他信息', 'url' => url('my-resume/other?id=' . $resume_id), 'setting' => ($resume->resume_ext->other_id !== '')),
        );
        self::set('lefter_naves', $lefter_naves);
        
        // 简历附加内容
        $lefter_append_naves = array(
            array('title' => '项目经验', 'url' => url('my-resume/project?id=' . $resume_id), 'setting' => ($resume->resume_ext->project_id !== '')),
            array('title' => '专业技能', 'url' => url('my-resume/skill_id?id=' . $resume_id), 'setting' => ($resume->resume_ext->skill_id !== '')),
            array('title' => '在校学习情况', 'url' => url('my-resume/study?id=' . $resume_id), 'setting' => ($resume->resume_ext->study_id !== '')),
            array('title' => '在校实践经验', 'url' => url('my-resume/practice?id=' . $resume_id), 'setting' => ($resume->resume_ext->practice_id !== '')),
        );
        self::set('lefter_append_naves', $lefter_append_naves);
        
        self::render();
    }
    
}